//
//  tabBarModel.m
//  testassembly
//
//  Created by liangang on 2018/3/8.
//  Copyright © 2018年 liangang. All rights reserved.
//

#import "tabBarModel.h"
@implementation vcModel
-(void)setValue:(id)value forKey:(NSString *)key
{
    [super setValue:value forKey:key];
    if([key isEqualToString:@"name"])
    {
        self.name = value;
       UIViewController     *vc =[[NSClassFromString(value) alloc] init];
        self.vc = vc;
    }
    
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}
@end
@implementation tabBarItemModel
-(void)setValue:(id)value forKey:(NSString *)key
{
    [super setValue:value forKey:key];
    if([key isEqualToString:@"vc"])
    {
        vcModel *model = [[vcModel alloc]init];
        [model setValuesForKeysWithDictionary:value];
        self.vc= model;
    }
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}
@end
@implementation tabBarModel
-(void)setValue:(id)value forKey:(NSString *)key
{
    [super setValue:value forKey:key];
    if([key isEqualToString:@"items"])
    {
        NSArray *array= value;
        NSMutableArray *temp = [[NSMutableArray   alloc]init];
        [array enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            tabBarItemModel *model = [[tabBarItemModel alloc]init];
            [model setValuesForKeysWithDictionary:obj];
            [temp addObject:model];
        }];
        self.items = [NSArray arrayWithArray:temp];
        
    }
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"%@",key);
}
@end
